<template>
	<view class="scroll-style">
		<scroll-view class="scroll-view" scroll-y>
			<image class="thumb" :src="model.imgs" mode="aspectFill"></image>
			<view class="title">{{model.title}}</view>
			<view class="view-white">
				<view class="subtitle-box">
					<image src="@/static/image/xmsm.png"></image>
					<text>项目说明</text>
				</view>
				<view class="content">
					<u-parse :content="model.content"></u-parse>
				</view>
			</view>
			<view class="view-white">
				<view class="subtitle-box">
					<image src="@/static/image/skjg.png"></image>
					<text>发起机构&收款机构</text>
				</view>
				<view class="jg-box">
					<image :src="model.organizationInfo.logo" mode="aspectFill"></image>
					<text>{{model.organizationInfo.name}}</text>
				</view>
				<view class="jg-list">
					<text class="tit">项目名称:</text>
					<text>{{model.title}}</text>
				</view>
				<view class="jg-list">
					<text class="tit">立项时间:</text>
					<text>{{model.createdAt}}</text>
				</view>
				<view class="jg-list">
					<text class="tit">项目金额:</text>
					<text class="money">¥{{model.amount | moneyFormatter}}</text>
				</view>
				<view class="jg-text">本公益项目已在慈善中国注册备案，捐款用途及明细可通过官网查询</view>
			</view>
			<view v-if="model.illuminate > 1" class="view-white">
				<view class="subtitle-box">
					<image src="@/static/image/axls.png"></image>
					<text>认领情况</text>
				</view>
				<view class="user-box">
					<image class="avatar" :src="model.wishClaim.avatar" mode="aspectFill"></image>
					<view class="user-list">
						<text>微信昵称: {{model.wishClaim.nickname}}</text>
						<text>真实姓名: {{model.wishClaim.name}}</text>
						<text>联系电话: {{model.wishClaim.phone}}</text>
					</view>
				</view>
			</view>
			<view style="width: 100%; height: 30rpx;"></view>
		</scroll-view>
		<view class="bottom-box">
			<view class="collect-box" @click="clickCollect">
				<block v-if="model.collect">
					<image src="../../static/image/ysc.png"></image>
					<text class="ysc">已收藏</text>
				</block>
				<block v-else>
					<image src="../../static/image/sc.png"></image>
					<text>收藏</text>
				</block>
			</view>
			<block v-if="model.illuminate == 1">
				<view class="status-box highlight" @click="clickClaim">
					<image src="@/static/image/ydl.png"></image>
					<text>我要认领</text>
				</view>
			</block>
			<block v-else-if="model.illuminate == 2">
				<view v-if="model.type" class="status-box highlight" @click="clickLighten">
					<image src="@/static/image/ydl.png"></image>
					<text>为他点亮</text>
				</view>
				<view v-else class="status-box">
					<image src="@/static/image/wtdl.png"></image>
					<text>已被认领</text>
				</view>
			</block>
			<block v-else-if="model.illuminate == 3">
				<view class="status-box">
					<image src="@/static/image/wtdl.png"></image>
					<text>执行中</text>
				</view>
			</block>
			<block v-else-if="model.illuminate == 4">
				<view class="status-box">
					<image src="@/static/image/wtdl.png"></image>
					<text>已圆梦</text>
				</view>
			</block>
		</view>
		<popup-wish-claim ref="claim" @claimSuccess="loadData"></popup-wish-claim>
		<wish-pay ref="pay" @paySuccess="loadData"></wish-pay>
	</view>
</template>

<script>
	import { detail, collect, pay } from '@/api/wish/index'
	export default {
		data() {
			return {
				show: false,
				id: undefined,
				model: {}
			}
		},
		onLoad(options) {
			this.id = options.id;
			this.loadData();
		},
		methods: {
			loadData() {
				detail(this.id, response => {
					this.model = response;
				})
			},
			
			/* 点击收藏和取消收藏 */
			clickCollect() {
				collect(this.id, response => {
					this.loadData();
				})
			},
			
			/* 认领心愿  */
			clickClaim() {
				this.$refs.claim.visible(this.model);
			},
			
			/* 点击点亮 */
			clickLighten() {
				this.$refs.pay.visible(this.model);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.scroll-view {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		flex: 1;
		overflow-y: auto;
	}
	
	.thumb {
		margin: 30rpx 30rpx 0;
		width: 690rpx;
		height: 400rpx;
		border-radius: 16rpx;
	}
	
	.title {
		margin: 20rpx 30rpx 40rpx;
		font-size: 36rpx;
		font-weight: bold;
		color: #000000;
		line-height: 50rpx;
	}
	
	.view-white {
		display: flex;
		flex-direction: column;
		margin: 30rpx;
		border-radius: 20rpx;
		padding: 30rpx;
		box-shadow: 0 0 16rpx rgba(0, 0, 0, 0.1);
		.subtitle-box {
			display: flex;
			align-items: center;
			font-size: 38rpx;
			color: #2F8CF8;
			font-weight: bold;
			image {
				width: 34rpx;
				height: 34rpx;
				margin-right: 10rpx;
			}
		}
		
		.content {
			margin-top: 30rpx;
			font-size: 30rpx;
			color: #494949;
		}
		
		.jg-box {
			display: flex;
			align-items: center;
			padding: 35rpx 0;
			font-size: 36rpx;
			color: #333333;
			font-weight: bold;
			border-bottom: 1rpx solid #e8e8e8;
			image {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				margin-right: 15rpx;
			}
		}
		
		.jg-list {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: #333333;
			font-weight: bold;
			margin-top: 30rpx;
			.tit {
				width: 140rpx;
			}
			.money {
				font-size: 36rpx;
				color: red;
				font-weight: bold;
			}
		}
		
		.jg-text {
			margin-top: 30rpx;
			font-size: 26rpx;
			color: #828282;
			text-align: center;
		}
		
		.user-box {
			display: flex;
			margin-top: 30rpx;
			.avatar {
				width: 90rpx;
				height: 90rpx;
				border-radius: 50%;
			}
			.user-list {
				display: flex;
				flex-direction: column;
				margin-left: 20rpx;
				color: #333;
				font-size: 28rpx;
				text {
					margin-bottom: 10rpx;
				}
			}
		}
	}

	
	.bottom-box {
		display: flex;
		align-items: center;
		box-shadow: 0px -4px 16px 1px rgba(0,0,0,0.1);
		padding: 10rpx 40rpx;
		box-sizing: border-box;
		.collect-box {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: #5D5D5D;
			width: 160rpx;
			text {
				margin-top: 5rpx;
			}
			image {
				width: 40rpx;
				height: 38rpx;
				margin-right: 10rpx;
			}
			.ysc {
				color: #FA7E04;
			}
		}
		
		.status-box {
			display: flex;
			align-items: center;
			justify-content: center;
			margin-left: 20rpx;
			height: 70rpx;
			line-height: 70rpx;
			flex: 1;
			background-image: linear-gradient(to right, #D9D9D8, #9A9B9A);
			border-radius: 70rpx;
			font-size: 28rpx;
			color: #fff;
			image {
				width: 45rpx;
				height: 37rpx;
				margin-right: 30rpx;
			}
			&.highlight {
				background-image: linear-gradient(to right, #F49C01, #ED810E);
			}
		}
	}
</style>